package com.example.demo.controller;

import com.example.demo.bean.InsertData;
import com.example.demo.bean.SimpleRetrieveData;
import com.example.demo.service.InsertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller

public class InsertController {
    @Autowired
    InsertService is;

    @RequestMapping(value= "Insert" , method = RequestMethod.POST)
    public InsertData simpleInsert(HttpServletRequest request){
        InsertData insertData=new InsertData();
        Map<String,String[]> map=request.getParameterMap();
        if(is.simpleInsert(map)){
            insertData.setCode(200);
            insertData.setMessage("Insert success");
        }
        else{
            insertData.setCode(500);
            insertData.setMessage("Insert Failed");
        }
        return insertData;
    }

}
